﻿--lua script
--#include "data\functions\Ride\RideCommon.lua" once			--坐骑功能方法

--[[坐骑相关
enum tagRideOp
{
	gRide_UpLevel		=	1,				//坐骑升级
};
]]

RideOpFuncList = {}

EventCallDispatcher.HandlerRideOp = function (sysarg, args)
  if args[1] == nil then return end   
  local func = RideOpFuncList[args[1]]
  if func ~= nil then
    func(sysarg, args) 
  end
end

--坐骑升级
RideOpFuncList[gRide_UpLevel] = function (sysarg,args)
	OnUpHorseLevelOp(sysarg,args)
end

--[[
EventCallDispatcher.HandlerCallRidePet = function ( sysarg )	
	local nLevel = Actor.getRideLevel(sysarg)
	local PetConfig = RideGameConfig.rideRankConfig[nLevel].pet
	if PetConfig then
		local thisPetCount = Pet.getPetCountById(sysarg, PetConfig.id)
		if thisPetCount > 0 then
			Actor.sendTipmsg(sysarg, string.format(Lang.Gem.t00050), ttFlyTip)
			return false
		end
		if Pet.addPet(sysarg, PetConfig.id, PetConfig.level, PetConfig.aiId, PetConfig.liveTime) > 0 then
			Actor.setIntProperty(sysarg,PROP_ACTOR_RIDEONID,0);	--坐骑ID
			Actor.setIntProperty(sysarg,PROP_ACTOR_MOUNTAPPEARANCE,0);	--坐骑外观
			Actor.removeState(sysarg,2); 		--去掉骑马状态
			Actor.setIntProperty(sysarg,PROP_ACTOR_RIDE_PETID,PetConfig.id);	--出战战斗坐骑ID
			Actor.collectOperate(sysarg,0);			
			Actor.addState(sysarg,31)
		end
	end
end

EventCallDispatcher.HandlerRemoveRidePet = function ( sysarg )
	local nPetID = Actor.getRidePetId(sysarg)
	if nPetID > 0 then
		local nCount = Pet.getPetCountById(sysarg, nPetID)
		if nCount > 0 then
			Pet.delPetById(sysarg, nPetID)
			Actor.removeState(sysarg,31)
		end						
	end
	Actor.collectOperate(sysarg,0);
end
]]
--EventCallDispatcher.rideHandleActorLevelUp = function(sysarg,args)
--end

--[[屏蔽坐骑
--玩家登陆
EventCallDispatcher.rideHandleActorLogin = function(sysarg,args)
	--等级判断
	local pLv = Actor.getIntProperty(sysarg,PROP_CREATURE_LEVEL)
	if pLv < RideGameConfig.openLevel then return end
	
	--是否已经有坐骑判断
	local rideFlag = Actor.getActorFlag(sysarg,0)
	if rideFlag > 0 then return end
	Actor.setIntProperty(sysarg,PROP_ACTOR_RIDE_LEVEL,1)
	Actor.setIntProperty(sysarg,PROP_ACTOR_MOUNTAPPEARANCE,1)
	Actor.setIntProperty(sysarg,PROP_ACTOR_RIDEONID,1)
	Actor.setActorFlag(sysarg,0)
	Actor.addState(sysarg,2)
	Actor.collectOperate(sysarg,0) -- 重新计算角色属性
end
--]]

EventCallDispatcher.registerEventCall(BaseTypes.ActorEventId.aeRideOp, EventCallDispatcher.HandlerRideOp)
--EventCallDispatcher.registerEventCall(BaseTypes.ActorEventId.aeCallRidePet, EventCallDispatcher.HandlerCallRidePet)
--EventCallDispatcher.registerEventCall(BaseTypes.ActorEventId.aeRemoveRidePet, EventCallDispatcher.HandlerRemoveRidePet)
--EventCallDispatcher.registerEventCall(BaseTypes.ActorEventId.aeLevel, EventCallDispatcher.rideHandleActorLevelUp)
--EventCallDispatcher.registerEventCall(BaseTypes.ActorEventId.aeUserLogin, EventCallDispatcher.rideHandleActorLogin)